import axios from '../axiosExtend.js'

class checkFacebook {
    constructor(out_name, fn){
        this.status = true;
        this.account = out_name;
        this.callBack = fn; // 回调函数
        this.checkFacebookAuthor();
    }
    checkFacebookAuthor() {
        let _this = this;
        $("<iframe id='facebookFrame' " +
        "name='facebookFrame' style='width: 730px;height: 315px;position:absolute;top: 50%;left: 50%;transform: translate(-50%,-50%);border:none;z-index: 10000;'>" +
        "</iframe>").prependTo('body');
        // $("#facebookFrame").attr("src","http://127.0.0.1:8848/shareHtml/fbadapter.html");

        window.addEventListener('message', function(e){
            if(e.data.type) {
                return;
            }
            let data = JSON.parse(e.data)
            if(data.cancel) {
                $("body").find("#facebookFrame").remove();
            }
        });
        _this.callBack(_this.status);
    }
}

export {
    checkFacebook
}